<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>v-on的参数传递问题</title>
    <script src="../lib/vue_v2.6.14.js"></script>
  </head>
  <body>
    <div id="app">
      <!-- 1、不传参数，()可以省略 -->
      <button @click="btn1Click">按钮1</button>

      <!-- 2、()省略时，默认传入 event 事件对象 -->
      <button @click="btn2Click">按钮2</button>

      <!-- 3、传递参数的同时，又需要 event 对象。固定写法：$event -->
      <button @click="btn3Click('张三', $event)">按钮3</button>
    </div>

    <script>
      const vm = new Vue({
        el: '#app',
        data: {
          message: '你好'
        },
        methods: {
          btn1Click() {
            console.log('按钮1')
          },

          btn2Click(e) {
            console.log('按钮2--', e)
          },

          btn3Click(name, e) {
            console.log(name, '----', e)
          }
        }
      })
    </script>
  </body>
</html>
